#pragma once

#include "entity/entity.h"
#include "render/rendermesh.h"

struct rendermaterial_t;

struct guitexture_t;
struct guitexture_renderobject_t:renderobject_t
{
	guitexture_renderobject_t(guitexture_t* _gt):gt(_gt){}
	void setupbuffers();
	void onrender();

	guitexture_t* gt;
};
struct guitexture_vertex_t
{
	float4 pos;
	float4 color;
	float2 uv;
};

struct guitexture_t:entity_t
{
	DECLARE_ENTITY;

	guitexture_t();
	void onload();
	void init();
	void setupbuffers();
	void onrender();
	void render();
	void setverts();
	void setcolor(const float4& color);
	void setscale(float _scaleHoriz,float _scale_Vert);
	void setuv(float _x,float _y);
#ifdef LEO_DESIGNER
	void onchangeproperty(const stringhash& propname);
#endif
	guitexture_vertex_t vert[4];

	rendermaterial_t* material;
	rendertexture_t* texture;
	vertexbuffer_t vb;

	guitexture_renderobject_t ro;

/*
	float act_top;
	float act_left;
	float act_width;
	float act_height;
*/
	float act_uvx;
	float act_uvy;
	float4 act_color;
	float act_hscale;

	//props
	float top;
	float left;
	float width;
	float height;
	float depth;

	float uvx;
	float uvy;
	float uvwidth;
	float uvheight;
	color4f color;
	stringhash texturename;
	bool background;
};


struct guitext_t;
struct guitext_renderobject_t:renderobject_t
{
	guitext_renderobject_t(guitext_t* _gt):gt(_gt){}
	void setupbuffers();
	void onrender();

	guitext_t* gt;

};

struct guitext_vertex_t
{
	float3 pos;
	float4 color;
	float2 uv;
};
struct guitext_t:entity_t
{
	DECLARE_ENTITY;

	guitext_t();
	void onload();
	void init();
	void setupbuffers();
	void onrender();
	void render();
	void setverts();
	void setcolor(const float4& _color);
	void setdepth(float _depth);
	void setpos(float2 _pos);
	void settext(const string& _text);

#ifdef LEO_DESIGNER
	void onchangeproperty(const stringhash& propname);
#endif
	vector<guitext_vertex_t> vert;

	vertexbuffer_t vb;

	guitext_renderobject_t ro;

	float2 act_pos;
	float4 act_color;
	float act_depth;
	float act_size;
	string act_text;


	//props
	float posX;
	float posY;
	float size;
	float depth;
	int	align;

	color4f color;
	string text;
};